package com.ruoyi.web.controller.api.cbs;

import cn.hutool.json.JSONUtil;
import com.ruoyi.cbs.contract.domain.vo.ContractorPersonnelSelectVo;
import com.ruoyi.cbs.contract.domain.vo.ContractorPersonnelVo;
import com.ruoyi.cbs.contract.domain.vo.ContractorSelectVo;
import com.ruoyi.cbs.contract.domain.vo.ContractorVo;
import com.ruoyi.cbs.contract.services.ContractorPersonnelServices;
import com.ruoyi.cbs.contract.services.ContractorServices;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.StringUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 承包商
 *
 * @author rsj
 * @date 2022-04-04
 */
@Slf4j
@Api("承包商信息")
@RestController
@RequestMapping("/api/contractor/personnel")
public class ApiContractorPersonnelController extends BaseController {


    @Autowired
    private ContractorServices contractorServices;
    @Autowired
    private ContractorPersonnelServices contractorPersonnelServices;

    @ApiOperation("查询承包商人员详情")
    @GetMapping("/detail/{personId}")
    public AjaxResult personalDetail(@PathVariable String personId)
    {
        if (StringUtils.isEmpty(personId)) {
            throw new ServiceException("请求异常！！！");
        }

        ContractorPersonnelVo personnelVo = contractorPersonnelServices.getContractorPersonnelDetail(personId);
        return AjaxResult.success(personnelVo);
    }

    /**
     * 查询承包商人员列表
     */
    @ApiOperation("查询承包商人员列表")
    @GetMapping("/select")
    public AjaxResult list(String contractorId, String personName)
    {
        if (StringUtils.isEmpty(contractorId)) {
            throw new ServiceException("传递参数值缺失！！！");
        }

        List<ContractorPersonnelSelectVo> list = contractorPersonnelServices.selectContractorPersonnelList(contractorId, personName);
        return AjaxResult.success(list);
    }







}

